package com.yesjpt.web;

import com.alibaba.fastjson2.JSONObject;
import com.yesjpt.serv.AliSmsServ;
import com.yesjpt.serv.ISmsServ;
import com.yesjpt.util.L;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms") // 上下文路径
public class SmsController {
	
	@Autowired private ISmsServ ISmsServ;
	
	@Autowired private AliSmsServ aliSmsServ;
	
	//小商家的短信发送
	@GetMapping("/send")
    public Object send(String phone, String content) {
		L.begin(new Throwable().getStackTrace()[0]);
    	return ISmsServ.sendMsg(phone, content);
    }
	//利用阿里发送验证码
	@GetMapping("/sendVerifyCode")
    public String sendVerifyCode(String phone) {
		L.begin(new Throwable().getStackTrace()[0]);
		JSONObject o = new JSONObject();
		o.put("code", "123456");//生产环境需要调用服务产生验证码
		return aliSmsServ.sendVerifyCode(phone, o);
    }
}
